<!DOCTYPE html>
<html lang="zh-cn">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <meta name="renderer" content="webkit">
  <title>网站信息</title>
  <link rel="stylesheet" href="../../css/pintuer.css">
  <link rel="stylesheet" href="../../css/admin.css">
  <script src="../../js/jquery.js"></script>
  <script src="../../js/pintuer.js"></script>
  <script src="../../js/jquery.form.js"></script>
</head>

<body>
  <div class="panel admin-panel">
    <div id="info"></div>
     
    <div class="panel-head"><strong><span class="icon-pencil-square-o"></span>修改费用</strong></div>
    <div class="body-content">
      <form class="form-x" id="assetForm" enctype="multipart/form-data">
        <div class="form-group">
          <div class="label">
            <label for="income">
              金额：</label>
          </div>
          <div class="field">
            <div class="input-group">
              <span class="addon">￥</span>
              <input class="input" type="text" id="money" name="price" placeholder="金额" /><span
                class="addon">元</span>
            </div>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label></label>
          </div>
          <div class="field" style="margin-top: 20px">
            <button class="button bg-main icon-check-square-o" type="button" id="agreementSub"> 提交</button>
          </div>
        </div>
      </form>
     
  </div>
</body>
<script>
  
  $(document).ready(function () {
    let result;
    var url=window.location.search; //获取url中"?"符后的字串
    console.log(url)
    if(url.indexOf("?")!=-1){
    result = url.substr(url.indexOf("=")+1);
    }

    $('#agreementSub').on('click', function () {
    console.log(result)
      $('#assetForm').ajaxSubmit({
        url: `http://127.0.0.1:3000/api/computer/updatecomputer`,
        type: 'get',
        dataType: 'jsonp',
        data: $('#assetForm').serialize(),
        success: function (data) {
          console.log(data)
          if (data.code == 1) {
            window.location.href = "./computer.html?info='操作成功' "
            
          } else if(data.code == 0){
            var str =
                `
                    <div class="alert alert-yellow">
                      <span class="close rotate-hover"></span><strong>注意：</strong>${data.msg}</div>
                    </div>
                `
            $('#info').html(str)
            setTimeout(function () {
              $('#info').html('')
            }, 2000)
          }
        },
        error: function (err) {
          console.log(err)
        },
        clearForm: false, //禁止清除表单
        resetForm: false //禁止重置表单
      })
    })
  })
</script>

</html>